// this file was added from scratch to the project by Josh Latvatalo
#include "Order_Item.h"
#include <string>
#include <fstream>
#include <iostream>
using namespace std;



// constructors
Order_Item::Order_Item (char seat, int ord_id, int menu_item, int qty) {
	seat_id = seat;
	order_id = ord_id;
	menu_item_id = menu_item;
	prod_qty = qty;
}

// utility functions
void Order_Item::display(){
	cout<< "The seat id was " << seat_id << "\n";
	cout<< "The order id was " << order_id<< "\n";
	cout<< "The menu item id was " << menu_item_id<< "\n";
	cout<< "The quantity ordered was " << prod_qty<< "\n";
}
int Order_Item::get_order_id(){//JTL B2.a
	return order_id;
}

int Order_Item::get_menu_item_id(){//JTL B2.a
	return menu_item_id;
}

int Order_Item::get_quantity(){//JTL B2.a
	return prod_qty;
}

void read_item(vector<Order_Item>& items, string file)
{
	
	ifstream file_in;
	file_in.open(file.c_str());
	if(file_in.fail())
	{
		cerr<<"\n ERROR, unable to open file\n";
	}
	else{
		int num_of_reads=0;
		file_in>>num_of_reads;
		for(int i=0; i <num_of_reads;i++)
		{
			int ord,serv,tab,y,m,d,h,min;
			file_in >> ord >> serv >> tab >> y >> m >> d >> h >> min;
		}	
		int count =0;
		num_of_reads=0;
		file_in>>num_of_reads;
		while(count<num_of_reads)
		{
			int order,menu_item,qty;
			char seat;
			file_in >> seat >> order >> menu_item >> qty;
			items.push_back(Order_Item(seat,order,menu_item,qty));
			count++;
		}
	}
}


